package com.speily.cloud.storage.service;

import com.speily.cloud.storage.dao.entity.Storage;
import com.speily.cloud.storage.dao.mapper.StorageMapper;
import com.speily.cloud.storage.exception.StorageException;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

/**
 * AccountServiceImpl
 *
 * @author : SPL
 * @since : 2021-04-20 11:41
 **/
@DubboService
@Slf4j
public class StorageServiceImpl implements StorageService {

    @Autowired
    private StorageMapper storageMapper;


    @Override
    public String decreaseStorage() {
        try {
            Storage s = new Storage();
            s.setId(1);
            s.setCount(99);
            //此处字段位数超长，抛异常
            s.setCommodityCode("phone33333333");
            storageMapper.updateById(s);
        }catch (Exception e){
            log.error("减库存异常", e);
            throw new StorageException(e.getMessage());
        }
        return "减库存";
    }
}
